import type { App } from 'vue'
import * as elementIcons from '@element-plus/icons-vue'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
// element-plus图标全局注册
const ElementIconsInstaller = {
  install: (app) => {
    for (const key in elementIcons) {
      const componentConfig = elementIcons[key]
      app.component(componentConfig.name, componentConfig)
    }
  },
}

export function setupElementPlus(app: App<Element>) {
  app
    .use(ElementPlus, {
      locale: zhCn,
    })
    .use(ElementIconsInstaller)
}
